package org.ht.controller;

import java.awt.HeadlessException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

import javax.swing.JOptionPane;

import org.azj.dbOperatorComponent.IJobManager;
import org.azj.logHelper.LOG;
import org.azj.logHelper.LOG_COMPONENT;
import org.azj.logHelper.LOG_LEVEL;

/**
 * 核心控制器
 * 
 * @author HT
 * 
 */
public class MainController {
	/**
	 * 事务处理
	 * 
	 * @param jobManager
	 * @return
	 * @throws HeadlessException
	 * @throws SQLException
	 */
	public static List<List<HashMap<String, Object>>> doJobsInTransaction(
			IJobManager jobManager) throws HeadlessException, SQLException {
		List<List<HashMap<String, Object>>> result;

		result = jobManager.doJobsInTransaction();
		if (null == result) {
			// 事务失败
			String errMsg = "事务提交失败，错误信息是 ： " + jobManager.getLastError() + "!";
			LOG.WriteLog(LOG_LEVEL.CRITICAL, LOG_COMPONENT.LOG_COMP_DB_CHANGE,
					errMsg);

			JOptionPane.showMessageDialog(null, errMsg, "错误",
					JOptionPane.ERROR_MESSAGE);
		}
		return result;
	}
}
